<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/WEB-INF/mytag.tld" prefix="f"%>
<%@page import="com.wy17113.model.service.*"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";

	int pageNum = (Integer) request.getAttribute("pageNum");
	int allpage = (Integer) request.getAttribute("allpage");
	int allCounts = (Integer) request.getAttribute("allCounts");
	List allScoreRecords = (List) request.getAttribute("allScoreRecords");

	String message = (String)request.getAttribute("message");
	if(null== message){
		message = "";
	}

	//个人
	int PsumScore = (Integer) request.getAttribute("PsumScore");//总积分
	int PreceivedScore = (Integer) request
			.getAttribute("PreceivedScore");//已领取积分
	int PunReceiveScore = (Integer) request
			.getAttribute("PunReceiveScore");//未领取积分
	int PcancelScore = (Integer) request.getAttribute("PcancelScore");//作废积分

	WebApplicationContext webContext = WebApplicationContextUtils
			.getRequiredWebApplicationContext(application);
	IUserService users = (IUserService) webContext
			.getBean("userService");
	IScoreRecordService srService = (IScoreRecordService) webContext
			.getBean("scoreRecordService");

	String uidOrAccount = request.getParameter("uidOrAccount");
	String uidOrAccountValue = request.getParameter("uidOrAccountValue");
	String uid = "";
	if (!uidOrAccount.equals("0")) {
		if (null != uidOrAccount && uidOrAccount.equals("account")) {
			uid = srService.getUserIdByAccount(uidOrAccountValue);
		} else {
			uid = uidOrAccountValue;
		}
	}
	int inviteNum = (int) users.getUserinviteNum(uid);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
	<HEAD>
		<base href="<%=basePath%>">
		<TITLE>北京 17113.cc</TITLE>
		<META http-equiv=Content-Type content="text/html; charset=gb2312">
		<LINK href="css/style.css" type=text/css rel=stylesheet>
		<script language="javascript" src="admin/js/calander.js"></script>
<SCRIPT>
function SetAllCheck(formObj, checkName) {
	var obj = eval("formObj."+checkName+";");
	if ( obj != null ) 
		for (var i=0; i<obj.length; i++) {
			obj[i].checked = formObj.allOper.checked;
		}
}

function DoReceive() {	
	var para = "";
    var ids = document.getElementsByName("recordIDList");
    for (var i=0;i<ids.length;i++ ){
     if(ids[i].checked){ //判断复选框是否选中
            para = para + ids[i].value + ",";
          }
    }
    var str1 = new Array();    
    str1 = para.split(",");
    var scoreNum = (str1.length -1) * 5;
	
	var state = document.getElementById("state").value;
	
	if(state != "-1"){
		alert("     该操作只能针对状态为\n未领取的积分纪录!请先选择查询条件:");
	}else{
		if(scoreNum < 1){
			alert("请选择要兑换的积分记录!");
		}else{
			if (confirm("     注意;只能兑换未领取状态的积分!\n" + "此次兑换积分为：" + scoreNum + ",确定要执行该操作吗?")) {
				window.location.href="doScore.do?opers1=doReceive&state=1&ids=" + para;
			} else {
				return;
			}
		}
	}
		
}

function DoCancel() {	
	var para = "";
    var ids = document.getElementsByName("recordIDList");
    for (var i=0;i<ids.length;i++ ){
     if(ids[i].checked){ //判断复选框是否选中
            para = para + ids[i].value + ",";
          }
    }
    var str1 = new Array();    
    str1 = para.split(",");
    var scoreNum = (str1.length -1) * 5;
	
	var state = document.getElementById("state").value;
	
	if(state != "-1"){
		alert("     该操作只能针对状态为\n未领取的积分纪录!请先选择查询条件:");
	}else{
		if(scoreNum < 1){
			alert("请选择要作废的积分记录!");
		}else{
			if (confirm("     注意;只能作废未领取状态的积分!\n" + "此次作废积分为：" + scoreNum + ",确定要执行该操作吗?")) {
				window.location.href="doScore.do?opers1=doReceive&state=0&ids=" + para;
			} else {
				return;
			}
		}
	}	
}
</SCRIPT>

		<META content="MSHTML 6.00.3790.2440" name=GENERATOR>
	</HEAD>
	<BODY text=#000000 bgColor=#ffffff leftMargin=0 topMargin=7>
	<form action="/doScore.do?opers1=getAllScore" method="post" id="form1" name="form1">
		<TABLE cellSpacing=0 cellPadding=0 width=800 align=center border=0>
			<TBODY>
				<TR>
					<TD align="center">						
						<IMG height=59 src="admin/img/logo-r.gif">
					</TD>
				</TR>
				<TR>
					<TD vAlign=top background=images/list-bg.jpg>
						<BR>
						<BR>
						<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=>	
								<TR>
									<TD>
											<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
												<TR>
													<td colspan=2 align="center" bgColor=#b4b4b4 height=24>
														<font size="3">积分纪录管理</font>																					
													</td>
												</TR>
												<TR>
													<td colspan=2 align="center" bgColor=#b4b4b4 height=24>
														<strong><font size="3"><%=message %></font></strong>																					
													<br></td>
												</TR>
												<TR>
													<td align=center>
														&nbsp;&nbsp;按积分状态查询：<select name="state" id="state">
															<option value="2" <%=request.getParameter("state").equals("2") ? "selected"
							: ""%>>所有</option>
															<option value="1" <%=request.getParameter("state").equals("1") ? "selected"
							: ""%>>已领取</option>
															<option value="-1" <%=request.getParameter("state").equals("-1") ? "selected"
							: ""%>>未领取</option>
															<option value="0" <%=request.getParameter("state").equals("0") ? "selected"
							: ""%>>已作废</option>
														</select>
														&nbsp;&nbsp;||&nbsp;&nbsp;按积分来源查询:														
														<select name="scoreType" id="scoreType">
															<option value="0" <%=request.getParameter("scoreType").equals("0") ? "selected"
							: ""%>>请选择</option>
															<option value="1" <%=request.getParameter("scoreType").equals("1") ? "selected"
							: ""%>>每日签到</option>
															<option value="2" <%=request.getParameter("scoreType").equals("2") ? "selected"
							: ""%>>邀请注册</option>
														</select><br/>
														&nbsp;&nbsp;按编号/帐号查询:
														<select name="uidOrAccount" id="uidOrAccount">
															<option value="0" <%=request.getParameter("uidOrAccount").equals("0") ? "selected"
							: ""%>>请选择</option>
															<option value="uid" <%=request.getParameter("uidOrAccount")
									.equals("uid") ? "selected" : ""%>>编号</option>
															<option value="account" <%=request.getParameter("uidOrAccount").equals(
									"account") ? "selected" : ""%>>帐号</option>
														</select>
														<input type="text" size="24" name="uidOrAccountValue" id="uidOrAccountValue" value="<%=request.getParameter("uidOrAccountValue") == null ? ""
							: request.getParameter("uidOrAccountValue")%>"/>	
													</td>
													<td align=center>
														<input type="submit" value="查询" />
													</td>													
												</TR>
												<TR>
													<td  align=center>
														&nbsp;&nbsp;按积分日期查询：
														开始日期:<input type="text" name="startTime" id="startTime" size="10" onclick="new Calendar(null, null, 1).show(this);"
										readonly="readonly" value="<%=request.getParameter("startTime") == null ? ""
					: request.getParameter("startTime")%>"/>
														&nbsp;&nbsp;结束日期:<input type="text" name="endTime"  id="endTime" size="10" onclick="new Calendar(null, null, 1).show(this);"
										readonly="readonly" value="<%=request.getParameter("endTime") == null ? ""
					: request.getParameter("endTime")%>"/>
													</td>
													<td align=center>
														[
														<A style="FONT-SIZE: 12pt; COLOR: #000099"
															href="/admin/adminIndex.jsp">返回控制台</A>]
													</td>
												</TR>
										</TABLE>
									</TD>
								</TR>
								<tr>
									<td>
										<table width="100%" border="1" cellspacing="1" cellpadding="0"
											bgcolor="737373" bordercolor="#FFFFFF">
											<tr>
												<td>
													<table width="100%" border="0" cellspacing="0"
														cellpadding="0">
														<tr>
															<td bgcolor="B4B4B4" height="20" align="center">
																总共<%=allCounts%>条 第<%=pageNum%>/<%=allpage%>页（每页显示100条）
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</table>
									</td>
								</tr>
							<TR>
								<TD>
									<TABLE cellSpacing=0 cellPadding=1 width="100%" border=1>
											<TBODY>
												<TR align="center">
													<TD class=text width=100 bgColor=#eff8e0 height=25>
														选中
													</TD>
													<TD class=text width=120 bgColor=#eff8e0 height=25>
														积分帐号
													</TD>
													<TD class=text width=120 bgColor=#eff8e0 height=25>
														积分
													</TD>
													<TD class=text width=120 bgColor=#eff8e0 height=25>
														积分状态
													</TD>
													<TD class=text width=120 bgColor=#eff8e0 height=25>
														积分来源
													</TD>
													<TD class=text width=120 bgColor=#eff8e0 height=25>
														积分日期
													</TD>
												</TR>
												<c:forEach var="record" items="<%=allScoreRecords%>">
													<TR align="center">
														<TD width=160 bgColor=#ffffff>
															<input type="checkbox" name="recordIDList" value="${record.id}">
														</TD>
														<TD width=80 bgColor=#ffffff>
															${record.account}
														</TD>

														<TD width=200 bgColor=#ffffff>
															${record.recordNum}
														</TD>
														<TD width=150 bgColor=#ffffff>											
															<c:if test="${record.state == '1' }">
																已领取
															</c:if>
															<c:if test="${record.state == '-1' }">
																未领取
															</c:if>
															<c:if test="${record.state == '0' }">
																已作废
															</c:if>
														</TD>
														<TD width=100 bgColor=#ffffff>
															<c:if test="${record.scoreType == '1' }">
																每日签到
															</c:if>
															<c:if test="${record.scoreType == '2' }">
																邀请注册
															</c:if>
														</TD>
														<td width=100 bgColor=#ffffff>
															${record.recordDate}
														</td>
													</TR>
												</c:forEach>
											</TBODY>
										</TABLE>
								</TD>
							</TR>
							<tr>
								<td>
									<table width="100%" border="1" cellspacing="1" cellpadding="0"
										bgcolor="737373" bordercolor="#FFFFFF">
										<tr>
											<td>
												<table width="100%" border="0" cellspacing="0"
													cellpadding="0">
													<tr>
														<td bgcolor="B4B4B4" height="20" align="center">
															<f:fenye className="doScore" para="opers1"
																functionName="getAllScore&state=${param.state}&startTime=${param.startTime }&endTime=${param.endTime }&scoreType=${param.scoreType }&uidOrAccount=${param.uidOrAccount }&uidOrAccountValue=${param.uidOrAccountValue }"
																pageNum="<%=pageNum%>" totalPage="<%=allpage%>" />
														</td>
													</tr>
												</table>
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<TR>
								<TD>
									<TABLE cellSpacing=0 cellPadding=1 width="100%" border="0">
										<TBODY>
											<TR>
												<td>
													&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
													<input type="checkbox" name="allOper"
														onClick="SetAllCheck(this.form, 'recordIDList')">
													<font color="#FF0000">全部选中</font>
												</td>
												<td align="right" colspan="5">
													<input type="button" name="operFlag" value=" 批量执行兑换 "
														onClick="javascript:DoReceive();"> ||
													<input type="button" name="operFlag1" value=" 批量执行作废 "
														onClick="javascript:DoCancel();">
												</td>
											</TR>
										</TBODY>
									</TABLE>
								</TD>
							</TR>
							<tr>
								<td>
										<table width="100%" border="1" cellspacing="1" cellpadding="0"
											bgcolor="737373" bordercolor="#FFFFFF">
											<tr>
												<td>
													<table width="100%" border="1" cellspacing="0"
														cellpadding="0">
														<tr>
															<td bgcolor="B4B4B4" height="20" rowspan="3"
																align="center">
																<strong>该用户积分情况：</strong>
															</td>
															<td bgcolor="B4B4B4" height="20">
																<strong><font color="green">总积分：</font><%=PsumScore%>
																</strong>
															</td>
															<td bgcolor="B4B4B4" height="20">
																<strong><font color="red">已兑换总积分：</font><%=PreceivedScore%>
																</strong>
															</td>
														</tr>
														<tr>
															<td bgcolor="B4B4B4" height="20">
																<strong><font color="red">作废总积分：</font><%=PcancelScore%>
																</strong>
															</td>
															<td bgcolor="B4B4B4" height="20">
																<strong><font color="green">剩余可用总积分：</font><%=PunReceiveScore%>
																</strong>
															</td>
														</tr>
														<tr>
															<td bgcolor="B4B4B4" height="20" align="center"
																colspan="2">
																<strong><font color="green">该用户已邀请人数：<%=inviteNum %></font>
																</strong>
															</td>
														</tr>
													</table>
												</td>
											</tr>
										</table>
									</td>
							</tr>						
						</TABLE>
					</TD>
				</TR>
			</TBODY>
		</TABLE>	
	</form>	
		<TABLE cellSpacing=0 cellPadding=5 width=800 align=center border=0>
			<TBODY>
				<tr>
					<td bgColor=#b4b4b4 height=5>
						&nbsp;
					</td>
				</tr>
				<tr>
					<td align="center">
						版权所有®2011 北京17113.cc. 保留所有权利. 冀ICP备11028198号
					</td>
				</tr>
			</TBODY>
		</TABLE>
	</BODY>
</HTML>





